//
//  BaseService.h
//  Baseproject
//
//  Created by gullmei on 15/9/11.
//  Copyright (c) 2015年 黄定坤. All rights reserved.
//

#import "GlobalConfig.h"

#define HuanXinAppKey @"1100190418042403#met"


//#define UMShareid @"5c358c87b465f56dd700099c"
#define UMShareid @"5cee33dd4ca357d46c000d83"

#define WXAppid @"wx21dc4d34086802b1"
#define WXAppKey @"5bf48901f07ff746143fcbcf2a408eb0"


#define  KUSER [UserModel shareModel].user
//开发地址
 
//服务器地址
//测试地址


#define HOST @"https://www.huangjingkeji.com/met/api-met/"

//#define HOST @"http://249y6964j3.wicp.vip:28287/api-met/"

#define IMAGEHOST @"https://www.youthwang.com:8080"

#define ICONURL(a) [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMAGEHOST,a]]





//域名服务器地址
//#define HOST @""

#define Response_Success @""
#define  NET_ERROR   -88

#import <Foundation/Foundation.h>

#import "AFHTTPSessionManager.h"
 //#import <LJFramework/LJFramework.h>
#import "BaseModel.h"
#import "TypeConversion.h"

#import <CommonCrypto/CommonDigest.h>


#define AA_WEAK_MAKE(var) __weak __typeof(&*self)
@interface ResResult : NSObject
@property (nonatomic, strong) id resData;
@property (nonatomic, assign) NSInteger resCode;
@property (nonatomic, copy) NSString *errMessage;
@end
enum ResponseType{
    TYPE_OBJECT=0, //返回一个对象
    TYPE_ARRAY=1, //返回一个数组
    TYPE_OTHER ,  //专门正对那些不规范的后台解码而设
};

typedef void(^NetworkServiceRequestResult)(id object , int code );  //ui使用的回调
typedef void(^SaveResponseData)(id data, int code ); //保存数据的回调
typedef id(^DecodeData)(id responseObject );  //解码的回调
//供ui使用：代理delegate
@protocol responseDelegate <NSObject>
- (void)responseWithObject:(id)obj resultCode:(int)rcode error:(NSError *)error;
@end

@interface BaseService : NSObject
{
    NSString * _notificationName;
    NSString *  _hostUrl;  //服务器地址
    NSMutableDictionary * _paramDict ;//请求参数
    Class     _modelclass;
    int    _reponseType;
}
@property(nonatomic, strong) NSString *notificationName; //回调通知
@property(nonatomic, strong)NSString * hostUrl; //服务器地址
/**
 图片
 */
@property(nonatomic ,strong) UIImage *icon;
/**
 图片数组
 */
@property(nonatomic ,strong) NSArray *iconArr;
/**
 图片的名称
 */
@property(nonatomic ,strong) NSString *iconName;
/**
 和后台对应的key
 */
@property(nonatomic ,strong) NSString *iconKey;



@property(nonatomic, strong)NSDictionary * paramDict;

@property(nonatomic,assign)int    reponseType;
@property(nonatomic,strong)NSString * sign;
@property(nonatomic, weak) id<responseDelegate> delegate; //回调代理

@property (nonatomic, copy) NetworkServiceRequestResult httpRequestResultBlock;
@property (nonatomic, copy) SaveResponseData saveToGlobalData;
@property (nonatomic, copy) DecodeData decodeData;
@property (nonatomic,assign) Class modelclass ;
@property(nonatomic,copy)NSString*keyStr;
/**
 *	@brief	初始化单例
 *
 *	@return	对象类
 */
+ (instancetype)getObject;

/**
 *	@brief	以post方式发送网络请求
 *
 *	@param 	urlString 	拼接好的URL
 *	@param 	param 	所要发送给服务器的参数
 *	@param 	aSuccess 	当返回数据时可以做定制化处理
 *
 */
- (void)postRequestWithUrl:(NSString *)urlString parameter:(id)param success:(id (^)(id responseObject, NSError *error))aSuccess;

/**
 *	@brief	接受回报处理函数
 */
-(void)OnRecvData:(id)data rcode:(int)code;
/**
 *	@brief	启动函数
 */
-(void)startPostRequest;
-(void)startGetRequest;


///上传图片
-(void)startUpload:(NSString *)name;
///上传图片数组
-(void)startUploadPhotoArr;
+ (NSString *)md5HexDigest:(NSString*)input;

@end
